home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-07 | 2.0 KB | 92 lines | [TEXT/MPS ] |
- (*
- CTBSendString string[,eom] -- Send a string out the current connection. If the eom parameter is
- present and non-empty, then set the end-of-message bit when sending.
-
- To compile and link this file using Macintosh Programmer's Workshop,
-
- pascal -w CTBSendString.p
- link -m ENTRYPOINT -o HyperCommands -rt XCMD=2754 -sn Main=CTBSendString ∂
- CTBSendString.p.o "{MPW}"Libraries:interface.o "{MPW}"Libraries:Libraries:HyperXLib.o
-
- © Copyright 1990 by Apple Computer, Inc.
-
- Initial coding 2/90 by Harry R. Chesley.
- *)
-
- {$R-}
-
- {$S CTBSendString } { Segment name must be the same as the command name. }
-
- unit DummyUnit;
-
- interface
-
- uses MemTypes, QuickDraw, OSIntf, ToolIntf, CTBUtils, FTIntf, CMIntf, TMIntf, CRMIntf, HyperXCmd;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- implementation
-
- procedure CTBSendString(paramPtr: XCmdPtr); forward;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- begin
- CTBSendString(paramPtr);
- end;
-
- procedure CTBSendString(paramPtr: XCmdPtr);
-
- {$I CTBUtil.inc}
-
- var i: integer;
- flags: CMFlags;
- p: Ptr;
- l: longInt;
- h: Handle;
- err: CMErr;
-
- procedure Fail(errMsg: Str255); { set theResult and quit }
- begin
- paramPtr^.returnValue := PasToZero(paramPtr,errMsg);
- exit(CTBSendString);
- end;
-
- begin
- { Check the parameter count. }
- i := paramPtr^.paramCount;
- if (i = 0) or (i > 2) then Fail('Invalid parameter count');
-
- { Check for an empty string being sent. }
- if not ParmPresent(1) then exit(CTBSendString);
- h := paramPtr^.params[1];
-
- { Make sure the Comm Toolbox is here. }
- CTBReady;
- { And so is a connection tool. }
- EnsurePresent(connectionTool);
- { And the connection is open. }
- EnsureOpen;
-
- { Figure the EOM flag setting. }
- if ParmPresent(2) then flags := cmFlagsEOM
- else flags := 0;
-
- { Count the number of bytes to be sent. }
- l := 0;
- p := h^;
- while p^ <> 0 do
- begin
- p := Ptr(ord4(p)+1);
- l := l+1;
- end;
-
- { Send 'em. }
- HLock(h);
- err := CMWrite(Globals^^.connHand,h^,l,cmData,false,nil,-1,flags);
- HUnlock(h);
- if err <> noErr then Fail('Write failed');
- end;
-
- end.
-